
<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        v-model="form"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        :permission="permissionList">
        <template slot="menuLeft">
          <el-button type="primary" size="small" @click="exportClick">导出</el-button>
        </template>
        <template slot="header" slot-scope="scope">
          <el-radio-group v-model="params.handleType" style="margin-bottom:10px">
            <el-radio-button :label="0">新办</el-radio-button>
            <el-radio-button :label="2">续期</el-radio-button>
            <el-radio-button :label="4">遗失补办</el-radio-button>
            <el-radio-button :label="5">非人为损坏补办</el-radio-button>
            <el-radio-button :label="6">人为损坏补办</el-radio-button>
            <el-radio-button :label="3">申退</el-radio-button>
          </el-radio-group>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import baseCrud from '@/mixins/base-crud'
import { startDate, endDate } from "@/const/crud/subway/swtkofficialtickethistorystaffCard";
import {
  dataExport
} from "@/api/subway/swtkofficialtickethistorystaffCard";
import { handleExcelResponse } from "@/util/util";

export default {
  name: "swtkofficialtickethistorystaffCard",
  mixins: [baseCrud('subway/swtkofficialtickethistorystaffCard')],
  data() {
    return {
      params: {
        handleType: "0"
      },
      searchForm: {
        //dates1: [startDate, endDate]
      }
    }
  },
  watch: {
    'params.handleType'(val){
      this.getList(this.page)
    }
  },
  computed: {
    permissionList() {
      return {
        addBtn: this.vaildData(
          this.permissions.st_swtkofficialtickethistory_add,
          false
        ),
        delBtn: this.vaildData(
          this.permissions.st_swtkofficialtickethistory_del,
          false
        ),
        editBtn: this.vaildData(
          this.permissions.st_swtkofficialtickethistory_edit,
          false
        )
      };
    }
  },
  methods: {
        
    async exportClick (row) {
      this.dataExport();
    },
    async dataExport () {
      this.searchForm.handleType = this.params.handleType
      let loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      })
      try {
        const res = await dataExport(Object.assign( this.searchForm ));
        handleExcelResponse(res);
      } finally {
        loading.close();
      }
    },
  }
};
</script>
